//
//  CirculateViewController.m
//  EDPS
//
//  Created by 张维扬 on 15/11/30.
//  Copyright © 2015年 张维扬. All rights reserved.
//

#import "CirculateViewController.h"
#import "MBProgressHUD.h"
@interface CirculateViewController ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, strong) MBProgressHUD *HUD;
@property (nonatomic, retain) UIView *webBrowserView;
@end

@implementation CirculateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = RGBA(253, 244, 233, 1);
    // webView
    [self createWebView];
    // 菊花
    [self createMBProgress];
    // 网络请求
    [self getNet];
}
#pragma mark - 小菊花
- (void)createMBProgress
{
    // 获取UIWebBrowserView
    self.webBrowserView = self.webView.scrollView.subviews[0];
    self.webBrowserView.backgroundColor = RGBA(253, 244, 233, 1);
    // 创建菊花
    self.HUD = [[MBProgressHUD alloc]initWithView:self.view];
    self.HUD.alpha = 0.5;
    [self.webBrowserView addSubview:self.HUD];
    self.HUD.labelText = @"加载中...";
    [self.HUD show:YES];
}
#pragma mark - 网络请求
- (void)getNet
{
    // 网路请求
    NSURLRequest *request = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:self.model.html_url]];
    NSLog(@"%@", self.model.html_url);
    [self.webView loadRequest:request];
}
#pragma mark - 创建webView
- (void)createWebView
{
    // 创建webView
    self.webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    self.webView.delegate = self;
    self.webView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.webView];
    
//    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [btn setFrame:CGRectMake(10, 20, 30, 30)];
//    btn.backgroundColor = [UIColor grayColor];
//    [self.webView addSubview:btn];
//    [btn setImage:[UIImage imageNamed:@"leftBack"] forState:UIControlStateNormal];
//    [btn addTarget:self action:@selector(go) forControlEvents:UIControlEventTouchUpInside];
    
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [self.HUD removeFromSuperview];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
